<?php
namespace app\index\controller;
use app\index\model\Userwater;
use app\index\model\Indent;
class Money extends Comm
{
    //财务记录
    public function index(){
        $userwater=new Userwater();
        $res=$userwater->AllMoney();
        return view('index',['res'=>$res]);
    }
    //收款单管理
    public function receipt(){
        $indent=new Indent();
        $res=$indent->StartData();
        $name=['dnumber','iname','uname','name','times','number','reality','uptimes','audit'];
        $tab=['订单编号','产品','购买人','代理商','下单时间','购买数量','成交价','完成时间','订单状态'];
        $table="收款单";
        //判断是否点击了Excel下载
        if (input('down')=="ok"){
            down($table,$res,$tab,$name);
        }
        return view('receipt',['name'=>$name,'tab'=>$tab,'table'=>$table,'res'=>$res,'url'=>'#']);
    }
    //财务报表的Excel下载
    public function export()
    {
        //下载Excel时需要的数据
        $userwater=new Userwater();
        $data=$userwater->AllMoney();
        $xls="财务报表";
        $name=['用户','变动','金额','时间','备注'];
        $table=['name','status','amount','times','comments'];
        down($xls,$data,$name,$table);
    }
}